<template>
<div class="main_spac1">
	<div class="main_white padding10 paddingTop0">
	<div class="main_ti box">
		<el-tabs v-model="activeName" @tab-click="handleClick" class="box">
			<el-tab-pane label="全部" name=""></el-tab-pane>
			<el-tab-pane label="备货中" name="2"></el-tab-pane>
			<el-tab-pane label="配送中" name="3"></el-tab-pane>
			<el-tab-pane label="已收货" name="4"></el-tab-pane>
			<el-tab-pane label="已取消" name="5"></el-tab-pane>
		</el-tabs>
		<!-- <el-checkbox
			v-model="look_canceled_list"
			class="marginLeft10"
			@change="canceledChange"
		></el-checkbox> -->
	</div>
	<div class="mainor_form">
		<div class="mainor_te">
			<!-- <router-link to="/order/list/add" class="mainor_tea">创建新订单</router-link> -->
			<!-- <el-button @click="importbuVisible = true">导入</el-button> -->
			<el-button @click="exportb">导出</el-button>
			<el-button @click="dialogFormVisible = true">表头设置</el-button>
		</div>
		<el-form
			:inline="true"
			:model="form"
			class="demo-form-inline"
			ref="userListFrom"
			label-width="70px"
		>
			<el-form-item label="客户名称">
				<el-autocomplete
					v-model="form.company_name"
					:fetch-suggestions="queryCustoms"
					placeholder="请输入客户名称"
					@select="selectCustom($event,'search')"
				>
					<template slot-scope="{ item }">
						<div>{{ item.company_name }}</div>
					</template>
				</el-autocomplete>
			</el-form-item>

			<el-form-item label="订单号" prop="order_sn">
			<el-input
				v-model.trim="form.order_sn"
				placeholder="订单号"
				clearable
				class="wid220"
			></el-input>
			</el-form-item>
			<el-form-item label="收货人" prop="contact" style="margin-right: 0">
			<el-input
				v-model.trim="form.contact"
				placeholder="收货人"
				clearable
				class="wid220"
			></el-input>
			</el-form-item>
			<el-form-item label="显示已取消订单：" label-width="130px">
			<el-radio-group v-model="form.look_canceled_list">
				<el-radio :label="1">是</el-radio>
				<el-radio :label="0">否</el-radio>
			</el-radio-group>
			</el-form-item>

			<div class="more el-form-item" @click="more">
			<span>更多</span>
			<i :class="[{ on: moredata }, ' el-icon-arrow-down']"></i>
			</div>
			<div class="clearfix"></div>
			<el-collapse-transition>
			<div v-if="moredata">

<!--#TODO  -->
				<el-form-item label="客户类型" >
					<el-select
						v-model="form.company_type_id"
						placeholder="客户类型"
						class="wid220"
						clearable
					>
					<el-option label="所有" value=""></el-option>
					<el-option
						v-for="(item,key) in list.company_type"
						:key="key"
						:label="item"
						:value="key"
					></el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="配送日期" prop="createTime">
					<el-date-picker
					v-model="createTime"
					type="daterange"
					class="time220"
					:editable="false"
					unlink-panels
					range-separator="至"
					start-placeholder="开始日期"
					end-placeholder="结束日期"
					value-format="yyyy-MM-dd"
					:clearable="false"
					:picker-options="pickerOptions"
					/>
				</el-form-item>

				<!-- <el-form-item label="配送时间" prop="send_time_id">
					<el-select
					v-model.trim="form.send_time_id"
					placeholder="配送时间"
					class="wid220"
					>
					<el-option label="所有" value=""></el-option>
					<el-option
						v-for="(send_time, index) in list.send_time"
						:key="index"
						:label="send_time"
						:value="parseInt(index)"
					></el-option>
					</el-select>
				</el-form-item> -->

				<el-form-item label="商品" prop="name">
					<el-input
					v-model.trim="form.name"
					placeholder="商品名称/别名/编码/助记码"
					clearable
					class="wid220"
					></el-input>
				</el-form-item>
				<el-form-item label="来源" prop="from">
					<el-select
					v-model.trim="form.from"
					placeholder="来源"
					class="wid220"
					>
					<el-option label="所有" value=""></el-option>
					<el-option
						v-for="(value, key, index) in list.fromList"
						:key="index"
						:label="value"
						:value="+key + 1"
					></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="打印" prop="is_print">
					<el-select
					v-model.trim="form.is_print"
					placeholder="打印"
					class="wid220"
					>
					<el-option label="所有" value=""></el-option>
					<el-option
						v-for="(is_print_list, index) in list.is_print_list"
						:key="index"
						:label="is_print_list"
						:value="parseInt(index + 1)"
					></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="下单日期" prop="placeTime">
					<el-date-picker
					v-model="placeTime"
					type="daterange"
					class="time220"
					:editable="false"
					unlink-panels
					range-separator="至"
					start-placeholder="开始日期"
					end-placeholder="结束日期"
					value-format="yyyy-MM-dd"
					:clearable="false"
					:picker-options="pickerOptions"
					/>
				</el-form-item>
				<el-form-item label="手机" prop="mobile">
					<el-input
					v-model.trim="form.mobile"
					placeholder="收货人手机"
					clearable
					class="wid220"
					></el-input>
				</el-form-item>
				<el-form-item label="支付状态" prop="pay_type">
					<el-select
					v-model.trim="form.pay_type"
					placeholder="支付状态"
					class="wid220"
					>
					<el-option label="所有" value=""></el-option>
					<el-option
						v-for="(pay_type_list, index) in list.pay_type_list"
						:key="index"
						:label="pay_type_list"
						:value="parseInt(index + 1)"
					></el-option>
					</el-select>
				</el-form-item>
				<div class="clearfix"></div>
			</div>
			</el-collapse-transition>
			<el-form-item class="marginTop10">
			<el-button class="reset marginLeft10" type="primary" @click="reset"
				>重置</el-button
			>
			<el-button
				type="primary"
				@click="getArticleList"
				:loading="listLoading"
				>搜索</el-button
			>
			</el-form-item>
		</el-form>
	</div>
	<div class="main_num boxdq">
		<div class="main_num_l boxha">
			<div class="mainsu_te marginRight5">
			<el-tooltip class="item" effect="dark" placement="top">
				<div slot="content">注释：今日新创建的订单</div>
				<svg aria-hidden="true" class="navbar_svg" width="16" height="16">
					<use xlink:href="#icon-summary_question" />
				</svg>
			</el-tooltip>
			</div>
			<p>
			新增订单：
			<em>{{ list.today_order_num }}</em>
			</p>
			<p>
			下单金额：
			<em>{{ list.today_order_money }}</em>
			</p>
			<div class="mainsu_te marginRight5">
			<el-tooltip class="item" effect="dark" placement="top">
				<div slot="content">注释：今日需配送的订单</div>
				<svg aria-hidden="true" class="navbar_svg" width="16" height="16">
					<use xlink:href="#icon-summary_question" />
				</svg>
			</el-tooltip>
			</div>
			<p>
			配送订单：
			<em>{{ list.today_send_num }}</em>
			</p>
			<p>
			下单金额：
			<em>{{ list.today_send_order_money }}</em>
			</p>
			<p>
			配送金额：
			<em>{{ list.today_send_money }}</em>
			</p>
			<p class="box" style="width: 400px; align-items: center">
			发货进度：
			<el-progress
				:text-inside="true"
				:stroke-width="15"
				:percentage="
					list.today_send_num == 0
					? 0
					: parseInt((list.today_sent_num / list.today_send_num) * 100)
				"
				status="success"
				color="#E47C02"
				style="width: 60%"
			></el-progress>
			</p>
			<!-- <span class="main_num_ls">（*统计以当天配送时间为准）</span> -->
		</div>
	</div>
	<div class="main_table">
		<el-table
			ref="multipleTable"
			v-loading="listLoading"
			:data="list.list.data"
			element-loading-text="加载中"
			fit
			border
			highlight-current-row
			@selection-change="handleSelectionChange"
		>
			<el-table-column type="selection" />
			<el-table-column
			label="订单号"
			prop="order_sn"
			:show-overflow-tooltip="true"
			/>
			<el-table-column
			label="客户名称"
			prop="nickname"
			:show-overflow-tooltip="true"
			width="150"
			>
			<template slot-scope="scope">
				{{ scope.row.company_name.company_name }}
			</template>
			</el-table-column>

			<el-table-column label="客户类型" :show-overflow-tooltip="true">
			<template slot-scope="scope">
				{{ list.company_type[scope.row.company_type] }}
			</template>
			</el-table-column>
			<!-- <el-table-column label="所属批发" :show-overflow-tooltip="true">
			<template slot-scope="scope">
				{{ scope.row.company_name_pf.company_name }}
			</template>
			</el-table-column> -->
			<div v-for="(field, index) in list.field" :key="index">
			<el-table-column
				label="下单日期"
				width="120"
				v-if="field == 3"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ parseTime(scope.row.created_at, "{y}-{m}-{d}") }}
				</template>
			</el-table-column>
			<el-table-column
				label="配送日期"
				width="120"
				:show-overflow-tooltip="true"
				v-if="field == 4"
			>
				<template slot-scope="scope">
					{{ parseTime(scope.row.send_time, "{y}-{m}-{d}") }}
				</template>
			</el-table-column>
			<el-table-column
				label="实付金额"
				prop="real_money"
				v-if="field == 5"
			/>
			<el-table-column
				label="配送金额"
				prop="send_money"
				v-if="field == 6"
			/>
			<el-table-column
				label="订单状态"
				prop="order_status"
				:show-overflow-tooltip="true"
				v-if="field == 7"
			>
				<template slot-scope="scope">
					<span
					:style="{ color: setColor('order', scope.row.order_status) }"
					>
					{{ list.order_status[scope.row.order_status] }}
					</span>
				</template>
			</el-table-column>
			<el-table-column
				label="支付状态"
				prop="pay_status"
				:show-overflow-tooltip="true"
				v-if="field == 8"
			>
				<template slot-scope="scope">
					<span :style="{ color: setColor('pay', scope.row.pay_status) }">
					{{ list.pay_type_list[scope.row.pay_status] }}
					</span>
				</template>
			</el-table-column>
			<el-table-column
				label="备注"
				prop="remark"
				:show-overflow-tooltip="true"
				v-if="field == 9"
			/>
			<el-table-column
				label="来源"
				prop="userNickname"
				:show-overflow-tooltip="true"
				v-if="field == 10"
			>
				<template slot-scope="scope">{{
					list.fromList[scope.row.from]
				}}</template>
			</el-table-column>
			<el-table-column
				label="打印"
				prop="is_print"
				:show-overflow-tooltip="true"
				v-if="field == 11"
			>
				<template slot-scope="scope">{{
					list.is_print_list[scope.row.is_print]
				}}</template>
			</el-table-column>
			<el-table-column
				label="收货人"
				prop="contact"
				:show-overflow-tooltip="true"
				v-if="field == 12"
			/>
			<el-table-column
				label="收货手机"
				prop="mobile"
				:show-overflow-tooltip="true"
				v-if="field == 13"
			/>
			<el-table-column
				label="收货地址"
				prop="address"
				:show-overflow-tooltip="true"
				v-if="field == 14"
			/>
			</div>
			<el-table-column
			label="管理操作"
			align="center"
			fixed="right"
			class-name="main_hei"
			>
			<template slot-scope="scope">
				<router-link :to="'/user/order_list/see/' + scope.row.id">
					<el-link type="success">查看</el-link>
				</router-link>
				<!-- <el-link>打印</el-link> -->
				<!-- <el-link
					type=""
					@click="(id = scope.row.id), successClick()"
					v-if="scope.row.order_status == 2"
					>完成</el-link
				> -->
			</template>
			</el-table-column>
		</el-table>
	</div>
	<div class="main_page boxdq">
		<div></div>
		<!-- 分页 -->
		<div class="main_page_r">
			<el-pagination
			:current-page="current.page"
			:page-sizes="[20, 30, 50, 100]"
			:page-size="limit"
			layout="total, sizes, prev, pager, next, jumper"
			:total="totalCount"
			background
			@size-change="changeLimit"
			@current-change="changePage"
			/>
		</div>
	</div>
	</div>

	<!-- 表头设置 -->
	<el-dialog
	title="表头设置"
	:visible.sync="dialogFormVisible"
	class="main_dialog dialog500"
	@close="type = list.field"
	>
	<el-checkbox-group v-model="type">
		<el-checkbox
			v-for="(Header, index) in Header"
			:key="index"
			:label="Header.id"
			:disabled="Header.disabled"
			>{{ Header.name }}</el-checkbox
		>
	</el-checkbox-group>
	<div slot="footer" class="dialog-footer">
		<el-button @click="dialogFormVisible = false">取 消</el-button>
		<el-button type="primary" @click="setupmine" v-repeatClick
			>确 定</el-button
		>
	</div>
	</el-dialog>
	<!-- 订单导入 -->
	<el-dialog
	title="订单导入"
	:visible.sync="importbuVisible"
	class="main_dialog dialog840 importbu"
	>
	<div class="importbu_p">
		<h3>导入说明：</h3>
		<p>1.注意使用红色字体标注的必填字段,不填或错填将导致导入失败。</p>
		<p>2.导入文件仅支持xlsx格式,大小不超过2M ,数据不超过2000行。</p>
		<p>3. 导入文件不能包含“合并单元格”，否则无法导入。</p>
		<p>4. 导入时只要有一行数据不正确，则导入失败。</p>
	</div>
	<div class="importbu_ul">
		<ul>
			<li>
			<p>选择商户标识</p>
			<el-radio-group v-model="impo.resource" :border="true">
				<el-radio :label="1">按商户编码导入</el-radio>
				<el-radio :label="2">按商户编码导入</el-radio>
			</el-radio-group>
			</li>
			<li>
			<p>选择商品标识</p>
			<el-radio-group v-model="impo.resource" :border="true">
				<el-radio :label="1">按SKU条码导入</el-radio>
				<el-radio :label="2">按商品编码导入</el-radio>
				<el-radio :label="3">按商品名称导入</el-radio>
			</el-radio-group>
			</li>
			<li>
			<p>价格定义方式</p>
			<el-radio-group v-model="impo.resource" :border="true">
				<el-radio :label="1">按系统定价导入</el-radio>
				<el-radio :label="2">按自定义价格导入</el-radio>
			</el-radio-group>
			</li>
		</ul>
	</div>
	<div class="importbu_in">
		<h3>数据行区间设置</h3>
		<div class="box">
			<p>
			<span>第一个数据行号：</span
			><el-input
				v-model.trim="form.name"
				placeholder
				clearable
				class="wid110"
			></el-input>
			</p>
			<p>
			<span>最后一行数据行数：</span
			><el-input
				v-model.trim="form.name"
				placeholder
				clearable
				class="wid110"
			></el-input>
			</p>
		</div>
	</div>
	<div class="importbu_an box">
		<el-button type="primary" @click="importbu" v-repeatClick
			>导入订单</el-button
		>
		<el-button>下载模板</el-button>
		<p>上传文件名：订单模板165416556565655.sxsl</p>
	</div>
	<div class="importbu_cw">错误信息：12行错误</div>
	<div slot="footer" class="dialog-footer">
		<el-button @click="importbuVisible = false">取 消</el-button>
	</div>
	</el-dialog>
	<!-- 订单导出 -->
	<el-dialog
	title="订单导出"
	:visible.sync="exportbuVisible"
	class="main_dialog dialog500"
	>
	<div v-if="selectArr.length == 0 ? true : false">
		<p class="exptitle">选择导出时间</p>
		<el-date-picker
			v-model="exportTime"
			type="daterange"
			range-separator="至"
			start-placeholder="开始日期"
			end-placeholder="结束日期"
			format="yyyy-MM-dd"
			value-format="yyyy-MM-dd"
		>
		</el-date-picker>
		<!-- <el-tooltip
			class="item"
			effect="dark"
			content="Top Center 提示文字"
			placement="top"
		>
			<i class="el-icon-question"></i>
		</el-tooltip> -->
	</div>
	<div>
		<p class="exptitle margintop">选择导出订单信息字段</p>
		<div>
			<el-checkbox-group v-model="exportHeaderType.orderList">
			<el-checkbox
				v-for="(Header, index) in exportOrderLsit"
				:key="index"
				:label="Header.id"
				:disabled="Header.disabled"
				>{{ Header.name }}</el-checkbox
			>
			</el-checkbox-group>
		</div>
		<div>
			<el-checkbox v-model="goodspicker"
			>导出商品信息
			<el-tooltip
				class="item"
				effect="dark"
				content="默认不勾选，则不导出商品信息"
				placement="top"
			>
				<i class="el-icon-question"></i> </el-tooltip
			></el-checkbox>
		</div>
	</div>
	<div v-if="goodspicker">
		<p class="exptitle margintop">选择导出商品字段信息</p>
		<el-checkbox-group v-model="exportHeaderType.goodsList">
			<el-checkbox
			v-for="(Header, index) in exportGoodsList"
			:key="index"
			:label="Header.id"
			:disabled="Header.disabled"
			>{{ Header.name }}</el-checkbox
			>
		</el-checkbox-group>
	</div>
	<div slot="footer" class="dialog-footer">
		<el-button @click="exportbuVisible = false">取 消</el-button>
		<el-button type="primary" @click="exportConfirm" v-repeatClick
			>确 定</el-button
		>
	</div>
	</el-dialog>
</div>
</template>

<script>
import dateOption from "@/options/dateOption";
import {
order_index,
order_export_info,
order_export,
getCompanyListByName
} from "@/api/order/orderList";
import { field_save, setting_company } from "@/api/currency";
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import { parseTime } from "@/utils/index";
import exportList from "@/options/export";

export default {
data() {
	return {
	// 时间
	parseTime,
	// 分页
	current: {
		page: 1,
		per_page: 20,
	},
	limit: 20,
	totalCount: 1,
	// 列表数据
	list: {
		today_sent_num: 0,
		today_send_num: 1,
		list: {
			data: [],
		},
		fromList: ["后台"],
		pay_type_list: ["未支付"],
		is_print_list: ["未打印"],
	},
	listLoading: false,
	// 搜索
	form: {
		name: "",
		is_print: null,
		from: null,
		// nickname: "",
		company_id: null,	//客户名称（对应id）
		company_type_id: null,	//客户类型
		order_sn: "",
		contact: "",
		start_time: "",
		end_time: "",
		create_start_time: "",
		create_end_time: "",
		send_time_id: null,
		mobile: "",
		order_status: null,
		pay_type: null,
		look_canceled_list: 0,
	},
	look_canceled_list: false,
	placeTime: [],
	createTime: [],
	pf_list: [], //所属批发列表
	pickerOptions: dateOption,
	// 选中菜单
	activeName: null,
	// 更多
	moredata: false,
	// 全选
	selectArr: [],
	// 表头设置
	dialogFormVisible: false,
	type: [],
	Header: [
		{
			id: 1,
			name: "订单号",
			disabled: true,
		},
		{
			id: 2,
			name: "商户名称",
			disabled: true,
		},
		{
			id: 15,
			name: "所属批发",
			disabled: true,
		},
		{
			id: 3,
			name: "下单日期",
			disabled: false,
		},
		{
			id: 4,
			name: "配送日期",
			disabled: true,
		},
		{
			id: 5,
			name: "下单金额",
			disabled: false,
		},
		{
			id: 6,
			name: "配送金额",
			disabled: true,
		},
		{
			id: 7,
			name: "订单状态",
			disabled: true,
		},
		{
			id: 8,
			name: "支付状态",
			disabled: false,
		},
		{
			id: 9,
			name: "备注",
			disabled: false,
		},
		{
			id: 10,
			name: "来源",
			disabled: false,
		},
		{
			id: 11,
			name: "打印",
			disabled: false,
		},
		{
			id: 12,
			name: "收货人",
			disabled: false,
		},
		{
			id: 13,
			name: "收货手机",
			disabled: false,
		},
		{
			id: 14,
			name: "收货地址",
			disabled: false,
		},
	],
	// id
	id: "",
	// 订单导入
	importbuVisible: false,
	impo: {
		resource: 1,
	},
	// 订单导出
	exportbuVisible: false,
	goodspicker: false, //商品信息 true
	exportOrderLsit: exportList.OrderList,
	exportGoodsList: exportList.GoodsList,
	// 默认的导出表头信息
	exportHeaderType: {
		orderList: [],
		goodsList: [],
	},
	// 订单导出时间
	exportTime: [],
	};
},
activated() {
	// 列表
	this.order_index();
},
// 刷新
inject: ["reload"],
methods: {
	// 勾选
	canceledChange(val) {
		let data = Object.assign(
			{
				sign: Md5(
				objKeySort(
					Object.assign(apiUrl().name, { look_canceled_list: val ? 1 : 0 })
				) + apiUrl().appsecret
				),
			},
			apiUrl().name,
			{ look_canceled_list: val ? 1 : 0 }
		);
		setting_company(data).then((res) => {
			if (res.errcode == 0) {
				this.order_index();
			} else {
				this.$message.error(res.errmsg);
			}
		});
	},
	// 完成
	examine() {
		let data = Object.assign(
			{
				sign: Md5(
				objKeySort(
					Object.assign(apiUrl().name, { id: this.id, status: 3 })
				) + apiUrl().appsecret
				),
			},
			apiUrl().name,
			{ id: this.id, status: 3 }
		);
		order_setOrderStatus(data).then((res) => {
			if (res.errcode == 0) {
				this.$message({
				message: "确认成功",
				type: "success",
				});
				this.order_index();
			} else {
				this.$message.error(res.errmsg);
			}
		});
		this.examineVisible = false;
	},
	successClick() {
		this.$confirm("确认订单商户已完成签收?", "提示", {
			confirmButtonText: "确定",
			cancelButtonText: "取消",
			type: "warning",
		})
			.then(() => {
				this.examine();
			})
			.catch(() => {});
	},
	// 导入订单
	importbu() {
		this.$confirm("excel为空", "提示", {
			confirmButtonText: "确定",
			cancelButtonText: "取消",
			type: "error",
		}).then(() => {});
	},
	// 选中菜单
	handleClick(tab, event) {
		this.form = {
			nickname: "",
			order_sn: "",
			contact: "",
			start_time: "",
			end_time: "",
			send_time_id: null,
			mobile: "",
			order_status: null,
			pay_type: null,
		};
		this.current = {
			page: 1,
			per_page: 20,
		};
		this.limit = 20;
		this.order_index();
	},
	// 更多
	more() {
		this.moredata = !this.moredata;
	},
	// 监听全选
	handleSelectionChange(val) {
		this.selectArr = [];
		val.map((item) => {
			this.selectArr.push({ id: item.id });
		});
	},
	// 导出框
	exportb() {
		let data = Object.assign(
			{
				sign: Md5(
				objKeySort(Object.assign(apiUrl().name)) + apiUrl().appsecret
				),
			},
			apiUrl().name
		);
		order_export_info(data).then((res) => {
			if (res.errcode == 0) {
				this.exportHeaderType.orderList = res.data.list.type_10;
				this.exportHeaderType.goodsList = res.data.list.type_11;
			}
			this.exportbuVisible = true;
		});
	},
	exportConfirm() {
		// 订单表头
		let orderList = [];
		this.exportOrderLsit.map((e) => {
			this.exportHeaderType.orderList.map((p) => {
				if (e.id == p) {
				orderList.push(e.id);
				return;
				}
			});
		});
		let goodsList = [];
		this.exportGoodsList.map((e) => {
			this.exportHeaderType.goodsList.map((p) => {
				if (e.id == p) {
				goodsList.push(e.id);
				return;
				}
			});
		});
		let ids = [];
		if (this.selectArr.length > 0) {
			this.selectArr.forEach((item) => {
				ids.push(item.id);
			});
		}
		let time = "";
		if (this.exportTime) {
			time = this.exportTime.join(" ");
		}
		let form = {
			ids: ids.join("-"),
			order_head: orderList.join("-"),
			list_head: goodsList.join("-"),
			is_status: this.goodspicker ? 1 : 0,
			send_time: time,
		};
		let data = Object.assign(
			{
				sign: Md5(
				objKeySort(Object.assign(apiUrl().name, form)) + apiUrl().appsecret
				),
			},
			apiUrl().name,
			form
		);
		if (!data.send_time && !data.ids) {
			this.$message.warning("请选择导出的时间段或导出的订单");
			return false;
		}
		// 储存导出的订单字段
		let data2 = Object.assign(
			{
				sign: Md5(
				objKeySort(Object.assign(apiUrl().name, { type: 10 })) +
					apiUrl().appsecret
				),
			},
			apiUrl().name,
			{
				type: 10,
				fields: JSON.stringify(orderList),
			}
		);
		// 储存导出的商品字段
		let data3 = Object.assign(
			{
				sign: Md5(
				objKeySort(Object.assign(apiUrl().name, { type: 11 })) +
					apiUrl().appsecret
				),
			},
			apiUrl().name,
			{
				type: 11,
				fields: JSON.stringify(goodsList),
			}
		);
		field_save(data2).then((res) => {
			if (res.errcode != 0) {
				this.$message.success("导出订单表头设置错误");
			}
		});
		field_save(data3).then((res) => {
			if (res.errcode != 0) {
				this.$message.success("导出商品表头设置错误");
			}
		});
		// 导出数据
		order_export(data).then((res) => {
			const link = document.createElement("a");
			let blob = new Blob([res], { type: "application/vnd.ms-excel" });
			link.style.display = "none";
			link.href = URL.createObjectURL(blob);
			document.body.appendChild(link);
			link.click();
			document.body.removeChild(link);
		});
		this.exportbuVisible = false;
	},
	// 设置确认
	setupmine(val) {
		let arry = [];
		this.Header.map((e) => {
			this.type.map((p) => {
				if (e.id == p) {
				arry.push(e.id);
				return;
				}
			});
		});
		let data = Object.assign(
			{
				sign: Md5(
				objKeySort(Object.assign(apiUrl().name, { type: 5 })) +
					apiUrl().appsecret
				),
			},
			apiUrl().name,
			{
				type: 5,
				fields: JSON.stringify(arry),
			}
			// [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
		);
		field_save(data).then((res) => {
			if (res.errcode == 0) {
				this.$message({
				message: "设置成功",
				type: "success",
				});
				this.reload();
			} else {
				this.$message.error(res.errmsg);
			}
		});
	},
	// 搜索
	getArticleList() {
		this.current.page = 1;
		this.order_index();
	},
	// 重置
	reset() {
		this.$refs["userListFrom"].resetFields();
		this.createTime = [];
		this.placeTime = [];
		this.order_index();
	},
	// 分页
	changeLimit(pageSize) {
		this.current.per_page = pageSize;
		this.order_index();
	},
	changePage(page) {
		this.current.page = page;
		this.order_index();
	},
	// 列表
	order_index() {
		this.listLoading = true;
		let data = Object.assign(
			{
				sign: Md5(
				objKeySort(
					Object.assign(apiUrl().name, this.list_form(), this.current, {
						status: this.activeName,
					})
				) + apiUrl().appsecret
				),
			},
			apiUrl().name,
			this.list_form(),
			this.current,
			{ status: this.activeName }
		);
		order_index(data).then((res) => {
			this.listLoading = false;
			if (res.errcode == 0) {
				res.data.list.data.map((e) => {
				let gs = 3;
				if (e.order_status == 0) {
					gs += 4;
				}
				if (e.order_status == 1) {
					gs += 3;
				}
				if (e.order_status == 2) {
					gs += 2;
				}
				if (e.order_status == 3) {
					gs += 1;
				}
				e.total = gs;
				e.show = false;
				});
				this.look_canceled_list =
				res.data.look_canceled_list == 1 ? true : false;
				this.type = res.data.field;
				this.list = res.data;
				this.totalCount = res.data.list.total;
			} else {
				this.$message.error(res.errmsg);
			}
		});
	},
	list_form() {
		let form = JSON.parse(JSON.stringify(this.form));
		form.start_time = this.createTime[0] ? this.createTime[0] : "";
		form.end_time = this.createTime[1] ? this.createTime[1] : "";
		form.create_start_time = this.placeTime[1] ? this.placeTime[1] : "";
		form.create_end_time = this.placeTime[1] ? this.placeTime[1] : "";

		return form;
	},
	setColor(type, status) {
		let color = "";
		if (type == "order") {
			switch (status) {
				case 0:
				color = "#F56C6C";
				break;
				case 1:
				color = "#118AB2";
				break;
				case 2:
				color = "#AACD6E";
				break;
				case 3:
				color = "#073B4C";
				break;
				case 4:
				color = "#CCCCCC";
				break;
				default:
				break;
			}
		} else if (type == "pay") {
			switch (status) {
				case 0:
				color = "#F56C6C";
				break;
				case 1:
				color = "#03A98E";
				break;
				default:
				break;
			}
		}
		return color;
	},
	//搜索客户列表
	queryCustoms(str,callback){
		let params = {company_name:str};
			let data = Object.assign(
			{
				sign: Md5(
					objKeySort(Object.assign(apiUrl().name,params)) +
					apiUrl().appsecret
				),
			},
			apiUrl().name,
			params
			);
		getCompanyListByName(data).then((res) => {
			if (res.errcode == 0) {
				callback(res.data.list)
			} else {
				this.$message.error(res.errmsg);
			}
		});
	},
	selectCustom(e,type){
		if(type == 'search'){
			this.form.company_id = e.id;
			this.form.company_name = e.company_name;
		}
	},
},
};
</script>
<style lang="scss" scoped>
.el-dropdown-menu--small .el-dropdown-menu__item {
padding: 2px 20px;
}

.main_ti {
margin-bottom: 15px;
padding-bottom: 1px;
position: relative;
/deep/.el-tabs__header {
	margin: 0;
}
/deep/.el-checkbox {
	margin-top: 12px;
}
&::after {
	height: 1px;
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	background-color: #e4e7ed;
	z-index: 1;
}
/deep/.el-tabs__nav-wrap::after {
	height: 0;
}
}
.main_num {
.mainsu_te {
	position: relative;
	top: -1px;
}
}

.main_dialog {
.main_table {
	/deep/.el-table__body-wrapper {
	overflow-y: auto;
	height: 300px;
	}
}
.main_xq ul li {
	width: 33.33%;
	margin-top: 5px;
	margin-bottom: 5px;
}
.examine_he {
	font-size: 16px;
	text-align: right;
	margin-top: 20px;
	span {
	color: red;
	}
}
}

// 导出订单表头
.exptitle {
display: block;
font-size: 16px;
color: #000000;
margin: 0 0 10px;
}
.margintop {
padding-top: 15px;
}
.el-checkbox-group {
display: flex;
flex-direction: row;
flex-wrap: wrap;
.el-checkbox {
	width: 26%;
}
}
</style>
